function SlashDamage takes nothing returns nothing
	local unit target = GetEnumUnit()
	local location targetLocation = GetUnitLoc(target)
	local real angle = AngleBetweenPoints(udg_TempCasterLocation , targetLocation)
	local real realDamage = udg_TempDamage
	//--
	if (IsUnitEnemy(target , udg_TempPlayer) and IsUnitInRangeLoc(target , udg_TempCasterLocation , udg_TempRadius) and not IsUnitType(target , UNIT_TYPE_STRUCTURE) and GetUnitState(target , UNIT_STATE_LIFE) > 0.0 and WithinAngle(angle , udg_TempCastAngle , udg_TempEffectiveAngle)) then
		set udg_TempHitCount = udg_TempHitCount + 1
		call UnitDamageTarget(udg_TempCaster , target , realDamage , true , false , ATTACK_TYPE_NORMAL , DAMAGE_TYPE_COLD , WEAPON_TYPE_METAL_MEDIUM_SLICE)
	endif
	call RemoveLocation(targetLocation)
	//--
	set target = null
	set targetLocation = null
endfunction

function SlashActionEffect takes nothing returns nothing
	local timer delayTimer = GetExpiredTimer()
	local integer timerId = GetHandleId(delayTimer)
	local real mastery = 0
	local unit caster = LoadUnitHandle(udg_HT , timerId , 0)
	local integer abilityLevel = GetUnitAbilityLevel(caster , 'A01K')
	local item weapon = LoadItemHandle(udg_HT , timerId , StringHash("WEAPON"))
	local real weaponDamage = LoadReal(udg_ItemDataHashTable , GetHandleId(weapon) , StringHash("WEAPON_DAMAGE"))
	local real weaponRangeBonus = LoadReal(udg_ItemDataHashTable , GetHandleId(weapon) , StringHash("RANGE_BONUS"))
	//--
	set udg_TempCaster = caster
	set udg_TempPlayer = GetOwningPlayer(caster)
	set mastery = LoadReal(udg_UnitDataHashTable , GetHandleId(caster) , StringHash("SLASH_MASTERY"))
	set udg_TempDamage = 20.0 + weaponDamage * 0.1 * mastery
	set udg_TempHitCount = 0
	set udg_TempRadius = 120.0 + weaponRangeBonus
	set udg_TempEffectiveAngle = 70.0
	set udg_TempCasterLocation = GetUnitLoc(caster)
	set udg_TempSpellTargetLocation = LoadLocationHandle(udg_HT , timerId , 1)
	set udg_TempCastAngle = AngleBetweenPoints(udg_TempCasterLocation , udg_TempSpellTargetLocation)
	call RemoveLocation(udg_TempSpellTargetLocation)
	call For(GetUnitsInRangeOfLocMatching(udg_TempRadius + 70.0 , udg_TempCasterLocation , null) , function SlashDamage)
	call UnitUsedAbilityWithDelta(caster , 'A01K' , 0.5 + 0.3 * I2R(udg_TempHitCount))
	
	call RemoveLocation(udg_TempCasterLocation)
	call PauseTimer(delayTimer)
	call FlushChildHashtable(udg_HT , timerId)
	call DestroyTimer(delayTimer)
	//--
	set delayTimer = null
	set caster = null
endfunction

function SlashAction takes nothing returns nothing
	local timer delayTimer = CreateTimer()
	local integer timerId = GetHandleId(delayTimer)
	local unit caster = GetTriggerUnit()
	//--
	call SaveUnitHandle(udg_HT , timerId , 0 , caster)
	call SaveLocationHandle(udg_HT , timerId , 1 , GetSpellTargetLoc())
	call SaveItemHandle(udg_HT , timerId , StringHash("WEAPON") , GetWeaponOfType(caster , StringHash("TWO_HANDED")))
	call TimerStart(delayTimer , 0.3 , false , function SlashActionEffect)
	call UnitPlayAnimation(caster , 33 , 2.0 , 0.4)
	//--
	set delayTimer = null
	set caster = null
endfunction

function Trig_Slash_Conditions takes nothing returns boolean
	return GetSpellAbilityId() == 'A01K'
endfunction

function InitTrig_Slash takes nothing returns nothing
	local hashtable masteryTable = InitHashtable()
	local integer abilityId = 'A01K'
	//--	
	call SaveInteger(udg_AbilityDataHashTable , abilityId , StringHash("NEXT_ABILITY") , 'A020')
	call SaveInteger(udg_AbilityDataHashTable , abilityId , StringHash("HOTKEY") , StringHash("E"))
	call SaveInteger(udg_AbilityDataHashTable , abilityId , StringHash("MASTERY_ID") , StringHash("SLASH_MASTERY"))
	call SaveStr(udg_AbilityDataHashTable , abilityId , StringHash("NAME") , "力劈")
	call SaveInteger(udg_AbilityDataHashTable , abilityId , StringHash("MAX_LEVEL") , 3)
	call SaveHashtableHandle(udg_AbilityDataHashTable , abilityId , StringHash("LEVEL_MASTERY_TABLE") , masteryTable)
	call SaveReal(masteryTable , 1 , 0 , 30.0)
	call SaveReal(masteryTable , 2 , 0 , 70.0)
	call SaveReal(masteryTable , 3 , 0 , 120.0)

	set gg_trg_Slash = CreateTrigger()
	call TriggerRegisterPlayerForceUnitEvent(gg_trg_Slash , EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_Slash , Condition(function Trig_Slash_Conditions))
	call TriggerAddAction(gg_trg_Slash , function SlashAction)
endfunction